package com.ssy.lingxi.order.entity;

import com.ssy.lingxi.order.model.bo.OrderTradeProcessBO;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单工作流任务
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-16
 */
@Entity
@Table(schema = "public", name = "ord_process_task")
public class OrderProcessTaskDO implements Serializable {
    private static final long serialVersionUID = -2526422607534279364L;

    public OrderProcessTaskDO() {
    }

    public OrderProcessTaskDO(OrderTradeProcessBO processBO, Integer processType) {
        this.processKey = processBO.getProcessKey();
        this.taskId = "";
        this.payTimes = processBO.getPayTimes();
        this.expireHours = processBO.getExpireHours();
        this.skipFirstStep = processBO.getSkipFirstStep();
        this.nextPay = false;
        this.nextSerialNo = 0;
        this.payStartNode = 0;
        this.payEndNode = 0;
        this.processType = processType;
    }

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_process_task_seq")
    @SequenceGenerator(sequenceName = "ord_process_task_seq", name = "ord_process_task_seq", allocationSize = 1)
    private Long id;

    /**
     * 流程的ProcessKey
     */
    @Column(columnDefinition = "varchar(50)")
    private String processKey;

    /**
     * 流程任务Id
     */
    @Column(columnDefinition = "varchar(50)")
    private String taskId;

    /**
     * 交易流程中配置的支付次数
     */
    @Column
    private Integer payTimes;

    /**
     * 逾期未支付自动取消订单的时间（小时）
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal expireHours;

    /**
     * 流程启动时，是否执行第一个任务
     */
    @Column
    private Boolean skipFirstStep;

    /**
     * 下一个任务是否是支付任务
     */
    @Column
    private Boolean nextPay;

    /**
     * 下一个任务如果是支付任务，支付批次
     */
    @Column
    private Integer nextSerialNo;

    /**
     * 起始的支付次数
     */
    @Column
    private Integer payStartNode;

    /**
     * 结束的支付次数
     */
    @Column
    private Integer payEndNode;

    /**
     * 订单流程类型，定义在 OrderProcessTypeEnum 中
     */
    @Column
    private Integer processType;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getProcessKey() {
        return processKey;
    }

    public void setProcessKey(String processKey) {
        this.processKey = processKey;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public Integer getPayTimes() {
        return payTimes;
    }

    public void setPayTimes(Integer payTimes) {
        this.payTimes = payTimes;
    }

    public BigDecimal getExpireHours() {
        return expireHours;
    }

    public void setExpireHours(BigDecimal expireHours) {
        this.expireHours = expireHours;
    }

    public Boolean getSkipFirstStep() {
        return skipFirstStep;
    }

    public void setSkipFirstStep(Boolean skipFirstStep) {
        this.skipFirstStep = skipFirstStep;
    }

    public Boolean getNextPay() {
        return nextPay;
    }

    public void setNextPay(Boolean nextPay) {
        this.nextPay = nextPay;
    }

    public Integer getNextSerialNo() {
        return nextSerialNo;
    }

    public void setNextSerialNo(Integer nextSerialNo) {
        this.nextSerialNo = nextSerialNo;
    }

    public Integer getPayStartNode() {
        return payStartNode;
    }

    public void setPayStartNode(Integer payStartNode) {
        this.payStartNode = payStartNode;
    }

    public Integer getPayEndNode() {
        return payEndNode;
    }

    public void setPayEndNode(Integer payEndNode) {
        this.payEndNode = payEndNode;
    }

    public Integer getProcessType() {
        return processType;
    }

    public void setProcessType(Integer processType) {
        this.processType = processType;
    }
}
